package demo3;


import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-17
 * Time: 13:33
 */


class Singleton {

    private static Singleton instance;

    private Singleton() {

    }

    //write your code here......
    public static Singleton getInstance() {
        return instance;
    }

}

public class Main3 {

    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1 == s2);
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            Sub1 sub1 = new Sub1(x, y);
            System.out.println(sub1.sum());
        }
    }

}

class Base1 {

    private int x;
    private int y;

    public Base1(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public final int getY() {
        return y;
    }

    public final int sum() {
        return getX() + getY();
    }

}

class Sub1 extends Base1 {

    public Sub1(int x, int y) {
        super(x, y);
    }

    //write your code here......
    //父类Base中定义了若干get方法，以及一个sum方法，sum方法是对一组数字的求和。请在子类 Sub 中重写 getX() 方法，使得 sum 方法返回结果为 x*10+y

    @Override
    public int getX() {
        return super.getX() * 10;
    }
}